﻿<#
   # 样例: INSERT INTO tablename (fieldName1,fieldName2,fieldName3,fieldName4) VALUES(?,1,?,?)
   #
   # 为了拼凑SQL中的INSERT语句,针对VALUES部分:
   # 针对需要插入值的字段,不是恒定值的字段,替换为?,恒定值的字段,不进行替换
#>
$resultFilePath =  "C:\Users\LQ\Desktop\result.txt "
#Remove-Item $filePath
$content = Get-Content "C:\Users\LQ\Desktop\d.txt" ;

$lst = $content.Split([System.Environment]::NewLine,[StringSplitOptions]::RemoveEmptyEntries);

$outputString = "";

for ($i = 0; $i -lt $lst.Count; $i++)
{ 
        $item =  $lst[$i];
         $xx = '';
         if ($item.Contains("'"))
         {
             $xx = $item;
         }
         else{
            $xx = '?,';
         }
        $outputString += [String]::Format('{0}',$xx);
}

$outputString >> $resultFilePath